// components/customScroller/index.js
Component({
    options: {
        styleIsolation: 'apply-shared',
        multipleSlots:true
      },
    /**
     * 组件的属性列表
     */
    properties: {
        emptySlot:{
            type:Boolean,
            value:false
        },
        loadmoreShow:{
            type:Boolean,
            value:false
        },
        scrollerId: {
            type: String,
            value:'coolui-scroller',
        },
        isEmpty: {
            type: Boolean,
            value: false,
        },
        isBackBtn: {
            type: Boolean,
            value: true,
        },
        baseRefreshConfig: {
            type: Object,
            value: ({
                shake: true, // 是否开启下拉震动
                height: 70,
                isAutoTriggered: false, //下拉刷新是否自动回弹
                text: {
                    color: "#999", // 文字颜色
                    shadow: 5, // 是否开启shadow阴影,0为不开启,数值越大阴影范围越大
                },
                background: {
                    color:"#fafafa",
                    // height: 120,
                    // img: "https://coolui.coolwl.cn/assets/bg.jpg",
                },
            })
        },
        emptySettingImg: {
            type: String,
            observer: function (newVal, oldVal) {
                const {
                    emptySetting
                } = this.data
                this.setData({
                    emptySetting: {
                        ...emptySetting,
                        img: newVal
                    }
                })
            }
        },
        emptySettingText: {
            type: String,
            observer: function (newVal, oldVal) {
                const {
                    emptySetting
                } = this.data
                this.setData({
                    emptySetting: {
                        ...emptySetting,
                        text: newVal
                    }
                })
            }
        },
        loadMoreSettingStatus: {
            type: String,
            observer: function (newVal, oldVal) {
                const {
                    loadMoreSetting
                } = this.data;
                this.setData({
                    loadMoreSetting: {
                        ...loadMoreSetting,
                        status: newVal
                    }
                })
            }
        }

    },

    /**
     * 组件的初始数据
     */
    data: {
        loadMoreSetting: {
            status: 'more', // [more | loading | noMore]
            moreText: '上拉加载更多',
            loadingText: '加载中...',
            noMoreText: '-- 到底啦 --',
            color: '#999',
        },
        emptySetting: {
            img: '/assets/image/empty.png',
            text: '暂无内容'
        }
    },

    /**
     * 组件的方法列表
     */
    methods: {
        scrollerRefresh() {
            this.triggerEvent('refresh')
        },
        scrollerLoadmore() {
            this.triggerEvent('loadmore')
        },
        settriggered(value) {
            this.selectComponent(`#${this.data.scrollerId}`)?.settriggered(value);
        }
    }
})